package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.entity.WeiboV01;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiboMapper {
    /**
     *
     * 1.微博表中插入数据
     * @param weibo
     * @return
     */
//    @Insert("INSERT INTO weibo(content,created,user_id) VALUES (#{content},#{created},#{user_id})")
    int insertWeibo(Weibo weibo);

    /**
     * 2.删除微博
     */
//    @Delete("DELETE FROM weibo WHERE id = #{id}")
    int deleteWeiboById(Long id);

    /**
     * 3.更新微博
     */
//    @Update("UPDATE weibo SET content = #{content},created = #{created},user_id = #{user_id} WHERE id = #{id}")
    void UpdateWeiboById(Weibo weibo);

    /**
     * 4.单条数据全字段查询:根据微博id查询该条微博的所有信息
     *  SELECT id,content,created,user_id From weibo WHERE id = #{wid}
     */
//    @Select("SELECT id,content,created,user_id From weibo WHERE id = #{wid}")
    Weibo selectWeiboById(Long wid);
    /**
     * 5.多条数据全字段查询:查询微博表中所有微博的所有信息
     */
//    @Select("SELECT id,content,created,user_id From weibo")
    List<Weibo> selectWeibo();
    /**
     * 6.单条数据部分字段查询:根据微博id查询该条微博的微博内容和发布时间
     *  SELECT context,create FROM weibo WHRER id = #{wid}
     */
//    @Select("SELECT content,created FROM weibo WHERE id = #{wid}")
    WeiboV01 selectWeiboV01ById(Long wid);
}
